<template>
  <!-- 输入密码 -->
  <u-popup v-if="isShowPsd" :show="isShowPsd" mode="center" round="20rpx">
    <view class="psdBox">
      <view class="psdTitle">请输入密码</view>
      <view class="psdInput">
        <u-input v-model="password" fontSize="32rpx" placeholderStyle="font-size: 28rpx;" placeholder="请输入密码" />
      </view>
      <view class="psdBtn">
        <view class="psdBtnItem cancel" @click="handlePsdCancel">取消</view>
        <view class="psdBtnItem confirm" @click="handlePsdConfirm">确定</view>
      </view>
    </view>
  </u-popup>
</template>

<script>
export default {
  props: {
    isShowPsd: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      password: "",
      realPasswords: "888888"
    }
  },
  created() {
  },
  methods: {

    // 取消
    handlePsdCancel() {
      this.$emit("handlePsdCancel");
    },
    // 确定
    handlePsdConfirm() {
      if (!this.password) {
        return uni.showToast({
          title: "请输入密码",
          icon: "none"
        });
      }
      if (this.password != this.realPasswords) {
        return uni.showToast({
          title: "密码错误",
          icon: "none"
        });
      }
      this.$emit("handlePsdConfirm", this.password);
    },
  }
}
</script>

<style lang="scss" scoped>
.psdBox {
  width: 60vw;
  padding: 20rpx 20rpx;
  border-radius: 20rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;

  .psdTitle {
    width: 100%;
    display: block;
    text-align: center;
    color: #323232;
    font-size: 32rpx;
  }

  .psdInput {
    width: 100%;
    margin: 20rpx 0;
  }

  .psdBtn {
    width: 100%;
    display: flex;

    .psdBtnItem {
      flex: 1;
      text-align: center;
      border-radius: 10rpx;
      padding: 10rpx;
      font-size: 28rpx;
    }

    .cancel {
      background: #fff;
      border: 2rpx solid #ebedf0;
    }

    .confirm {
      background: #3c9cff;
      color: #fff;
      margin-left: 20rpx;
    }
  }
}
</style>
